﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="UStatementDetail.ascx.cs"
    Inherits="PayRoller.Include.UStatementDetail" %>
<style type="text/css">
    .style1
    {
        font-size: 20px;
        font-weight: bold;
    }
    
    .tableSumary
    {
        text-align: center;
        font-weight: bolder;
    }
    
    .tableContent
    {
        text-align: center;
    }
    
    .myTable, .myTable td, .myTable th
    {
        border: 1px solid #000000;
        border-collapse: collapse;
    }
</style>
<table width="770" border="0" cellspacing="1" cellpadding="1" align="center" class="NormalText">
    <tr>
        <td>
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td width="50%">
                        <img runat="server" id="picLogo" src="../images/logo.jpg" width="202" height="78" />
                    </td>
                    <td style="line-height: 130%" width="50%">
                        Golden Bridge Enterprises (Aust) Pty Ltd<br />
                        ABN: 92 112 483 226<br />
                        PO BOX 18323, Collins Street East, VIC 8003<br />
                        Tel: 1300 137 906<br />
                        Fax: 1300 138 916
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td height="40">
            <div align="center">
                <p align="center" class="style1">
                    Account Statement</p>
            </div>
        </td>
    </tr>
    <tr>
        <td>
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td>
                        <table width="100%" border="0" cellspacing="1" cellpadding="1">
                            <tr>
                                <td height="22">
                                    ABC P/L:<asp:Label ID="labOrgName" runat="server" Text="Label"></asp:Label>
                                </td>
                            </tr>
                            <tr>
                                <td height="22">
                                    Attn:<asp:Label ID="labContactPerson" runat="server" Text="Label"></asp:Label>
                                </td>
                            </tr>
                            <tr>
                                <td height="22">
                                    Address:
                                    <asp:Label ID="labAddress" runat="server" Text="Label"></asp:Label>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>
                        <table width="100%" border="0" cellspacing="1" cellpadding="1">
                            <tr>
                                <td width="50%">
                                    <table width="100%" border="0" cellspacing="1" cellpadding="1">
                                        <tr>
                                            <td height="22">
                                                Date:<asp:Label ID="labStatementDate" runat="server" Text="Label"></asp:Label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td height="22">
                                                No:<asp:Label ID="labStatementID" runat="server" Text="Label"></asp:Label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td height="22">
                                                Ref:<u><asp:Label ID="labOrgID" runat="server" Text="Label"></asp:Label></u>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                                <td width="50%" valign="top">
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>
                        <table width="100%" border="0" cellspacing="1" cellpadding="1">
                            <tr>
                                <td width="50%">
                                    &nbsp;
                                </td>
                                <td width="50%">
                                    &nbsp;
                                </td>
                            </tr>
                            <tr>
                                <td valign="top">
                                    <table width="380" border="0" cellpadding="1" cellspacing="1" class="myTable">
                                        <tr>
                                            <th height="24">
                                                Your account summary
                                            </th>
                                        </tr>
                                        <tr>
                                            <td style="line-height: 150%">
                                                Credit Limit:<asp:Label ID="labCreditLimit" runat="server" Text="Label"></asp:Label><br />
                                                Closing Balance:<asp:Label ID="labClosingBalance" runat="server" Text="Label"></asp:Label><br />
                                                Credit Available:<asp:Label ID="labAvailableBalance" runat="server" Text="Label"></asp:Label>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                                <td valign="top">
                                    <table width="380" cellspacing="1" cellpadding="1" class="myTable">
                                        <tr>
                                            <th height="22">
                                                Payment Information
                                            </th>
                                        </tr>
                                        <tr>
                                            <td height="22">
                                                Total Invoice Amount:<asp:Label ID="labTotalInvoiceAmount" runat="server" Text="Label"></asp:Label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td height="22">
                                                Total Penalty:<asp:Label ID="labTotalPenalty" runat="server" Text="Label"></asp:Label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td height="22">
                                                Total Late Interest Charges:<asp:Label ID="labTotalLateInterestCharges" runat="server"
                                                    Text="Label"></asp:Label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td height="22">
                                                Total Payable:<asp:Label ID="labTotalPayable" runat="server" Text="Label"></asp:Label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td height="22">
                                                Payment Method: Direct Debit
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>
                        <br />
                        <table width="100%" border="0" cellspacing="1" cellpadding="1" class="myTable">
                            <tr>
                                <th height="22">
                                    <div align="center">
                                        Invoice No</div>
                                </th>
                                <th>
                                    <div align="center">
                                        Invoice Date</div>
                                </th>
                                <th>
                                    <div align="center">
                                        Invoice Amount</div>
                                </th>
                                <th>
                                    <div align="center">
                                        Penalty</div>
                                </th>
                                <th>
                                    <div align="center">
                                        Late Interest Charges</div>
                                </th>
                                <th>
                                    <div align="center">
                                        Payment Received</div>
                                </th>
                                <th>
                                    <div align="center">
                                        Amount Payable</div>
                                </th>
                                <th>
                                    <div align="center">
                                        Due Date</div>
                                </th>
                            </tr>
                            <%
                                decimal allInoviceAmount = 0.00M;
                                decimal allPenalty = 0.00M;
                                decimal allLateInterestCharges = 0.00M;
                                decimal allFee = 0.00M;
                                decimal allDiff = 0.00M;
                                decimal allPaid = 0.00M;

                                for (int i = 0; i < StatementInvoiceList.Count; i++)
                                {
                                    HySoft.Cash.Structure.HySoft.Cash.Structure.TStatementInvoiceDT currentInvoice = StatementInvoiceList[i];
                                    DateTime invoiceDate = currentInvoice.InvoiceDate;
                                    string invoiceID = currentInvoice.OriginalInvoiceID.ToString();
                                    string invoiceDateString = invoiceDate.ToString(HySoft.Cash.AppSettings.DateFormatAU, HySoft.Cash.AppSettings.CurrentCulture);
                                    DateTime invoiceDueDate = invoiceDate.AddDays(56);
                                    string invoiceDueDateString = string.Empty;
                                    if (invoiceDueDate <= HySoft.Cash.SafeDateTime.LocalToday)
                                    {
                                        invoiceDueDateString = "Immediately";
                                    }
                                    else
                                    {
                                        invoiceDueDateString = invoiceDueDate.ToString(HySoft.Cash.AppSettings.DateFormatAU, HySoft.Cash.AppSettings.CurrentCulture);
                                    }

                                    decimal invoiceAmount = currentInvoice.Principal + currentInvoice.Interest;
                                    decimal invoicePenalty = currentInvoice.Penalty;
                                    decimal invoiceLateInterestCharges = currentInvoice.LateInterestCharges;

                                    decimal invoiceFeeNeed = invoiceAmount + invoicePenalty + invoiceLateInterestCharges;
                                    decimal invoiceFeePaid = currentInvoice.InterestPaid + currentInvoice.LateInterestChargesPaid + currentInvoice.PenaltyPaid + currentInvoice.PrincipalPaid;
                                    decimal invoiceDiff = invoiceFeeNeed - invoiceFeePaid;
                                    string invoiceDiffString = invoiceDiff.ToString("0.00");

                                    allInoviceAmount += invoiceAmount;
                                    allPenalty += invoicePenalty;
                                    allLateInterestCharges += invoiceLateInterestCharges;
                                    allFee += invoiceFeeNeed;
                                    allPaid += invoiceFeePaid;
                                    allDiff += invoiceDiff;
                            %>
                            <tr>
                                <td height="22" class="tableContent">
                                    <%=invoiceID %>
                                </td>
                                <td>
                                    <%=invoiceDateString %>
                                </td>
                                <td class="tableContent">
                                    <%=invoiceAmount %>
                                </td>
                                <td class="tableContent">
                                    <%=invoicePenalty %>
                                </td>
                                <td class="tableContent">
                                    <%=invoiceLateInterestCharges %>
                                </td>
                                <td class="tableContent">
                                    <%=invoiceFeePaid%>
                                </td>
                                <td class="tableContent">
                                    <%= invoiceDiffString%>
                                </td>
                                <td class="tableContent">
                                    <%=invoiceDueDateString %>
                                </td>
                            </tr>
                            <%
}
                            %>
                            <tr>
                                <td height="22" class="tableSumary">
                                    Totals
                                </td>
                                <td class="tableSumary">
                                </td>
                                <td class="tableSumary">
                                    <%=allInoviceAmount.ToString("0.00")%>
                                </td>
                                <td class="tableSumary">
                                    <%=allPenalty.ToString("0.00")%>
                                </td>
                                <td class="tableSumary">
                                    <%=allLateInterestCharges.ToString("0.00") %>
                                </td>
                                <td class="tableSumary">
                                    <%=allPaid.ToString("0.00")%>
                                </td>
                                <td class="tableSumary">
                                    <%=allDiff.ToString("0.00") %>
                                </td>
                                <td class="tableSumary">
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td height="30" align="left">
            <div align="center">
                <a href="#" onclick="window.print();">Print</a>
            </div>
        </td>
    </tr>
</table>
